package com.prototype.deepclone;

import java.io.Serializable;

/**
 * 最为被拷贝对象的一个 属性值
 * 实现Cloneable接口，主要为了通过clone的方式实现深拷贝
 * 实现Seriable接口，主要为了通过 序列化的方式实现深拷贝
 */
public class DeepCloneTarget implements Serializable, Cloneable {

    private String name;

    private String age;

    public DeepCloneTarget(String name, String age) {
        this.name = name;
        this.age = age;
    }

    @Override
    protected Object clone() {
        DeepCloneTarget deepCloneTarget = null;
        try {
            deepCloneTarget = (DeepCloneTarget) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return deepCloneTarget;
    }
}
